﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TuyenSinh.BLL;
using TuyenSinh.Class;

namespace TuyenSinh.Admin
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Admin"] != null)
            {
                Response.Redirect("Defaul.aspx");
            }
        }

         protected void btnLogin_Click(object sender, EventArgs e)
        {
            string sUsername = txtUsername.Text.Trim();
            string sPassword = txtPassword.Text.Trim();
            
            var bBuser = new BUser();


            bool bResLogin = bBuser.LoginAdmin(sUsername, sPassword, 1);

            if (bResLogin)
            {
                var oCus = new CUser();
                oCus.UserN = sUsername;
                oCus.Password = sPassword;
                oCus.RoleId = 1;
                Session["Admin"] = oCus;
                Response.Redirect("Default.aspx");

            }
            else
                spRes.Text = "Username or password incorrect";

        }
    }
}